package com.example.check_oa.dubbo;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.example.check_oa.model.mapper.HolidayApMapper;
import com.example.comment_oa.pojos.attendance.HolidayAp;
import com.example.check_oa.model.service.HolidayTypeService;
import com.example.comment_oa.dubbo.HoliDubbo;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.Date;

@DubboService(version = "1.0.0",protocol = "${dubbo.protocol.id}",
        application = "${dubbo.application.id}",registry = "${dubbo.registry.id}",
        timeout = 3000)
public class HoliDubboImpl implements HoliDubbo {
    @Resource
    HolidayApMapper holidayApMapper;
    @Resource
    HolidayTypeService holidayTypeService;

    @Override
    public int apHoli(HolidayAp holidayAp, MultipartFile file) {
        return holidayTypeService.add(holidayAp, file);
    }

    @Override
    public int yesHoli(String hoId, String yesUser) {
        UpdateWrapper<HolidayAp> wrapper=new UpdateWrapper<>();
        wrapper.eq("ho_water",hoId);
        HolidayAp holidayAp=new HolidayAp();
        holidayAp.setHoApYesTime(new Date());
        holidayAp.setHoYesUser(yesUser);
        holidayAp.setHoState(1);
        return holidayApMapper.update(holidayAp,wrapper);
    }

    @Override
    public int noHoli(String hoId, String yesUser) {
        UpdateWrapper<HolidayAp> wrapper=new UpdateWrapper<>();
        wrapper.eq("ho_water",hoId);
        HolidayAp holidayAp=new HolidayAp();
        holidayAp.setHoApYesTime(new Date());
        holidayAp.setHoYesUser(yesUser);
        holidayAp.setHoState(2);
        return holidayApMapper.update(holidayAp,wrapper);
    }
}
